package com.yxw.yxnet_cd_center.customer_service.controller;

import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.yxnet_cd_center.customer_service.dto.ExportStandStatisticsDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.StandStatisticsQueryDTO;
import com.yxw.yxnet_cd_center.customer_service.service.StandStatisticsService;
import com.yxw.yxnet_cd_center.customer_service.vo.StandStatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author fangmaoxin
 * @version 1.0
 * @date 2023年9月22日
 * 客服维护统计-控制层
 */
@RestController
@Api(value = "客服维护统计管理", tags = "客服维护统计管理")
@Slf4j
@RequestMapping("/stand_statistics/v1")
public class StandStatisticsController {

    @Autowired
    private StandStatisticsService standStatisticsService;


    /**
     * 查询渠道活跃度统计列表
     */
    @PostMapping("/list")
    @ApiOperation(value = "查询客服维护统计列表")
    public BaseResult<PageVO<StandStatisticsVo>> list(@RequestBody StandStatisticsQueryDTO dto) {
        PageVO<StandStatisticsVo> channelStatisticsList = standStatisticsService.selectStandStatisticsList(dto);
        return ResultHelper.fillWithSuccess(channelStatisticsList);
    }

    /**
     * 导出数据
     */
    @PostMapping("/exportExcel")
    @ApiOperation(value = "导出客服维护管理数据")
    public void exportExcel(HttpServletResponse response, @RequestBody ExportStandStatisticsDTO dto) {
        standStatisticsService.exportExcel(response, dto);
    }


    /**
     * 根据客服Id获取客服维护统计数据
     */
    @GetMapping("/getStandStatisticsByUserId/{userId}")
    @ApiOperation(value = "根据客服Id获取客服维护统计数据")
    public BaseResult getStandStatisticsByUserId(@PathVariable Long userId) {
        StandStatisticsVo result = standStatisticsService.getStandStatisticsByUserId(userId);
        return BaseResult.doSuccess(result, "获取成功！");
    }

    /**
     * 进行客服维护统计
     */
    @PostMapping("/standStatistics")
    @ApiOperation(value = "进行客服维护统计")
    public BaseResult insertStandStatistics() {
        standStatisticsService.insertStandStatistics();
        return BaseResult.doSuccess(null, "进行客服维护统计成功");
    }

}
